using UnityEditor;
using UnityEngine;

namespace SimpleEditor
{
    public class EditorCommonTool
    {
        public static void LoadAssetIfNull<T>(string path, ref T data) where T : Object
        {
            if (data == null)
            {
                data = AssetDatabase.LoadAssetAtPath<T>(path);
            }
        }
        
        
        public static void CheckAndResizeTextureSize(ref Texture2D texture2D, int width, int height)
        {
            if (texture2D == null)
            {
                texture2D = new Texture2D(width, height);
            }
            else
            {
                if (texture2D.width != width || texture2D.height != height)
                {
                    texture2D.Resize(width, height);
                }
            }
        }
    }
}